/*
 * Copyright (c) 2006, 2021, webrx.cn All rights reserved.
 *
 */
package org.beiyou;

/**
 * <p>Project: javase - Abc
 * <p>Powered by webrx On 2021-12-01 08:57:22
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 17
 */
public class Abc {
    static {
        int i = 6;
        System.out.println(i * i);
    }

    int i = 3;

    {
        System.out.println("hello");
    }

    public static void main(String[] args) {
        //AA a1 = new AA();
        //System.out.println(a1.pf(3));

        //A a2 = new AA();
        //System.out.println(a2.pf(6));

        //Abc a = new Abc();

        System.out.println(DbService.sum(3, 5));

        //函数式接口 lambda 表达式，没有内部匿名类没有，
        //DbService ds = i -> i * i;

        //System.out.println(ds.pf(16));

        //DbService ds = new DbMysql();
        //System.out.println(ds.pf(3));
        //System.out.println(ds.lf(9));
        //System.out.println(DbService.sum(3, 6));

        DbService ds = i -> i * i;//接口中有且只有一个抽象方法，可以使用lambda表达式
        System.out.println(ds.pf(3));//抽象
        System.out.println(ds.lf(9));//default
        System.out.println(DbService.sum(3, 6));//static


        System.out.println(max(new int[]{16, 26, 36, 15}, 56, 100, 58));


        ///Date d = new Date();
        //System.out.println(d instanceof String);
        //System.out.println(d instanceof Date);

    }

    public static int max(Object... o) {
        int m = Integer.MIN_VALUE;
        if (o.length == 0) {
            m = 0;
        } else if (o.length == 1) {
            if (o[0] instanceof Integer) {
                m = Integer.parseInt(o[0].toString());
            } else if (o[0] instanceof int[]) {
                for (int oo : (int[]) o[0]) {
                    if (m < oo)
                        m = oo;
                }
            } else if (o[0] instanceof int[][]) {
                for (int[] ii : (int[][]) o[0]) {
                    m = max(ii);
                }
            }
        } else {
            for (Object a : o) {
                if (a instanceof int[]) {
                    if (m < max(a)) {
                        m = max(a);
                    }
                } else {
                    if (a instanceof Integer && m < Integer.parseInt(a.toString())) {
                        m = Integer.parseInt(a.toString());
                    }
                }
            }
        }
        return m;
    }
}
